#!/usr/bin/env php
<?php

define('APPLICATION_ENV', 'development');
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    './',
    get_include_path(),
)));

require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);

$options = $application->getBootstrap()->getOptions();

Doctrine_Manager::connection($options['resources']['doctrine']['connection_string'], 'doctrine');

$manager = Doctrine_Manager::getInstance();

// set aggressive loading to make sure migrations are working
$manager->setAttribute(
    Doctrine_Core::ATTR_MODEL_LOADING,
    Doctrine_Core::MODEL_LOADING_AGGRESSIVE
);

$manager->setAttribute(Doctrine_Core::ATTR_TBLNAME_FORMAT, $options['resources']['doctrine']['table_name_format']);

require_once 'vendor/sfYaml/sfYaml.php';

$cli = new Doctrine_Cli($options['doctrine']);

$cli->run($_SERVER['argv']);
